package es.juanc.threads.sync;

public class Cuenta {

	private String code;
	private int saldo;

	public Cuenta( String code, int saldoInicial ) {
		this.code = code;
		saldo = saldoInicial;
	}

	public synchronized void deposita( int cantidad ) {
		this.saldo += cantidad;
	}

	public synchronized void retira( int cantidad ) {
		this.saldo -= cantidad;
	}

	public synchronized int getSaldo() {
		return saldo;
	}

	public String getCode() {
		return code;
	}

	@Override
	public String toString() {
		return "Cuenta [code=" + code + ", saldo=" + saldo + "]";
	}
}